home *** CD-ROM | disk | FTP | other *** search
- Path: news.uh.edu!cosc19z5
- From: cosc19z5@Bayou.UH.EDU (Spasmo)
- Newsgroups: comp.lang.c,comp.unix.programmer
- Subject: Re: Q: '\n' character
- Followup-To: comp.lang.c,comp.unix.programmer
- Date: 13 Apr 1996 08:55:02 GMT
- Organization: University of Houston
- Message-ID: <4knq56$789@masala.cc.uh.edu>
- References: <4kj66f$k0o@ren.cei.net> <4kko80$8np@news.ld.centuryinter.net> <4kkvvsINN8fs@keats.ugrad.cs.ubc.ca> <4kmdsv$ojc@masala.cc.uh.edu> <4kmhpsINN7ak@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: bayou.uh.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Kazimir Kylheku (c2a192@ugrad.cs.ubc.ca) wrote:
- : In article <4kmdsv$ojc@masala.cc.uh.edu>, Spasmo <cosc19z5@Bayou.UH.EDU> wrote:
- : >Actually from where I'm standing this is the comp.unix.programmer newsgroup.
- : >Don't you love crossposting? It also means that the response was in fact on
- : >topic for us, but apparently not for you--the price of crossposting.
-
- : Oops, I didn't notice that.
-
- Well you should have. Or do you just blindly post articles without
- even looking at where they are going? Maybe this will be a lesson
- to you to actually pay attention to what you are doing.
-
-
- [Snip]
-
- : >The strlen() response was right, however it had the possibility of producing
- : >undesired effects under certain conditions. The user wanted a way to remove
-
- : So how is it right if it had undesired effects under certain conditions?
-
- The same way a myriad of other algorithms and solutions are right even
- though they may provide little or no error checking. If a person
- asked about allocating memory, a dozen people would respond "malloc"
- and provide sample code, which might not check the return. Does that
- make the sample code any less valid? No. It's a solution but error
- checking has been left out for brevity.
-
-
- : >newlines, and the response above did it. Of course in the case of a overly
-
- : It did not. It removed the last character of the buffer.
-
- Which is usually the newline. Read up on fgets, it's obvious you don't
- know what it does.
-
-
- : >long line, the response would remove a valid character--however the fact
-
- : And of course, *real* UNIX users don't put lines longer than 79 chars into a
- : textfile anyway...
-
- Do you think you could actually say something without dripping sarcasm
- and animosity all over the place? If you are interesting in discussing
- this matter, then try to behave maturely and try to keep this on a civil
- level.
-
-
- : >remains that it does remove the newline, and with the addition of some minor
- : >code can be made much safer--yet no one has shown the boundary conditions
- : >because it's obvious that they can exist, and they are easy to accomodate.
-
- : If they are easy to accomodate, why not write it properly in the first place?
-
- Because it's *EASY TO ACCOMODATE*. In the case where a complex test would
- be required I'd add it in, however this was simple enough that I saw no
- reason to add in extra code.
-
-
- : Humor me as to why it is necessary to retain a whole string of data just to
- : then scan through it to find its length to remove the trailining newline, which
- : was put there by a standard library function that already scanned the
- : characters once to _find_ the newline in the first place.
-
-
- That question should be asked of the person who wanted the help. I
- responded to his request for newline stripping *PERIOD*. He did not
- ask for an analysis of his design.
-
-
- : >Also given the application, the conditions that would make the strlen()
- : >solution unsafe may not even occur.
-
- : Is this representative of your general attitude toward software design, or do
- : you properly reserve it for writing trivial half-a-pagers?
-
- Do you know the exact details of his application? No. Do you know the
- nature (precise nature, not just "text file"), of the file he's trying
- to process? No. It's possible the file was produced by some process
- where lines are of a guaranteed length, and he's got a buffer large enough
- to accomodate them, newline included. Of course it's possible that this
- isn't the case. My point is we don't have the kind of intimate details
- available about his environment and the circumstances of his program
- to make any assumptions. Hence we make none.
-
-
- : > So, the details of making the solution
- : >more robust are left out.
-
- : s/more robust/correct/
-
- : A robust program is one that deals gracefully with bad input, not one that
- : manages to avoid failure with valid input. A robust program that doesn't want
- : to deal with long lines will define these as invalid input, and then somehow
- : handle their occurence.
-
- *Yawn*. So can you give us a definition of "gracefully", or is this just
- another one of your catch phrases that you so enjoy throwing around?
-
-
- : > Perhaps this is an unwarranted assumption, however
- : >it was an assumption that was made--at least in my case. I was one of the
- : >folks who suggested the strlen() solution as I use it when needed (with
- : >proper checks of course). And in case you haven't noticed, the strlen() fix
- : >is directed at newline stripping which *IS* the right question. Go back
- : >and re-read the original post.
-
- : Better yet, why don't I repost it?
-
- : Hello everybody,
- : Is there a function or some sort of way that I could remove '\n'
- : charecter form the end of the string. I'm reading from two files, want to
- : form one line of text and then have it printed out to stdout. I use fgets to
- : read from the file and I noticed that it appends newline char at the end.
- : It is important that two lines of text, one from each file, will be
- : combined into one and I can't do it because the first string has '\n' added
- : to it. I'm picky becauuse the output will be used to feed another program and
- : I'm affraid that not properly formatted input may corrupt the process.
- : Any suggestions will be greatly appreciated .. Thanks, Art ...
-
- : Tell me again how I answered the wrong problem with my solution, and how you
- : answered the right one with your non-solution?
-
- He asked about newlines. You told him to rewrite his program. I answered
- on how to strip newlines. Therefore you are wrong and I am right.
-
-
- : >And yes there are better solutions to the problem. I like the strchr solution
- : >posted by a few folks and will probably use that in preference to
- : >strlen(), however it does not take away from the validity of the original
-
- : Ah yes. And then there is that fellow who insists that he has never seen a UNIX
- : system in which it was impossible to do *strchr(string, '\n') = '\0' regardless
- : of whether there actually is a '\n' character inside ``string''. Simply
- : brilliant!
-
-
- Kindly refrain from insulting others. In case you haven't noticed, you
- are looking like quite an ass already so you shouldn't be commenting
- on the "brilliance" of others.
-
-
-
- : >And using UNIX commands to achieve what you need instead of C is far
- : >more elegant, far less typing, far more robust, and far easier than
- : >any code you can write. Get a grip the guy above is discussing using
-
- : I agree, but sadly, I had not noticed this was crossposted to a UNIX
- : newsgroup.
-
-
- Ordinarily a forgivable mistake, but given your attitude I can't let
- this pass. You can't even tell where an article is getting crossposted
- and you criticize others? You expect others to listen to you? Pardon
- me while I laugh.
-
-
- : >UNIX utilities instead of re-inventing the wheel. And he's got a very
-
- : Right, but in comp.lang.c, not everyone is a UNIX user.
-
- Crossposting again. This thread has a bit of both so...
-
-
- : >valid point. With all the beautiful tools available under UNIX we can
- : >get a lot done without having to write any code. As it stands people
- : >jump into a compiler to fix problems that can be better fixed without
- : >writing software. He has a very valid point. You'd do well to stop
- : >babbling and start listening.
-
- : I know my UNIX tools well, but I'm not going to push the beautiful beasties
- : onto Mac, OS/2, Windows or VMS programmers that may be reading comp.lang.c. I
- : do use UNIX and advocate it and its tools elsewhere, like comp.os.*.advocacy.
-
- Tsk tsk tsk, what did we just agree upon? This is a crossposted article.
-
-
-
- : Other than that I can _babble_ all I want---I earn that right by posting
- : correct answers that are tested to work, and get the poor newbie on the right
- : track, which is what these two newsgroups are for. I never flamed the one who
- : started this thread with a honest programming question, just the incorrect,
- : useless help he was getting which is worse than no help at all.
-
- You have earned nothing. Everyone on a newsgroup should practice a degree
- of etiquette. I don't care if you answered a billion questions in your
- life, that doesn't give you the right to insult. And as for posting
- good answers, you have yet to do that!
-
-
- : Why should I _listen_ to you? You can't even post a solution to a trivial
- : problem without overcomplicating it and buggering it up.
-
- And why should anyone listen to you? You can't even read a simple article
- properly! A user asks about stripping newlines and you tell him to rewrite
- his program. Then you have the audacity to insult the others who unlike
- you actually *ANSWERED* his questions. Had you even had a semblence of
- decency about the whole thing, your whole idiotic rant might have been
- tolerable, but you couldn't even do that!
-
-
- I find it utterly humorous that I post a line of code without error
- checking and I'm accused of overcomplicating and buggering up by a guy
- who tells the poster to re-write the whole thing!
-
- : --
-
-
- --
-
- .A. G-Force! 1 AM Houston Time
- AAAAA On the Cartoon Network!
- AAY:YAA
- A':::`A This informative message was
- ::::::: brought to you by Spasmo.
- ::( )::
- :::::::
- :::::::
- :::::::
- :::::::
- .A. .do:::::::::::bo. .A.
- AAA .:::::::::::::::::::::. AAA
- d:::::::::::::::::::::::::::::::::::::::::::b
- Y:::::::::::::::::::::::::::::::::::::::::::Y
- `YjY `:::::::|::|::|:::::::' YjY'
- `::|::|::|::'
- |
-